package com.jd.webapp.portal.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jd.cms.pojo.Content;
import com.jd.cms.service.ContentService;


@Service
public class ContentServiceDtoImpl implements ContentServiceDto {
	@Autowired
	private ContentService contentService;

	@Override
	public List<Map<String, Object>> getContentByCid(long cid) throws Exception {
		List<Content> contents = contentService.getContentsByCid(cid);

		List<Map<String, Object>> lists = new ArrayList<Map<String, Object>>();
		
		for (Content content : contents) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("srcB", content.getPic2());
			map.put("height", 240);
			map.put("alt", content.getTitle());
			map.put("width", 670);
			map.put("src", content.getPic());
			map.put("widthB", 550);
			map.put("href", content.getUrl());
			map.put("heightB", 240);
			lists.add(map);
		}
		return lists;
	}

}
